<template>
  <div class="luotong">
    <div class="content_title">
      <span class="content_text">络筒</span>
      <img
        class="content_img"
        src="@/assets/img/chart/luotong.png"
        alt=""
        srcset=""
      />
    </div>
    <div class="luotong_body">
      <div class="luotong_row1"></div>
      <div class="luotong_row2">
        <div
          class="item"
          v-for="(item, index) in luoTongData.luotongRow1Data"
          :key="index + '1'"
        >
          <div v-if="index == 3 || index == 11">
            <div class="dongli" @click="clickHandleDl('luotong2_' + index)">
              <img src="@/assets/img/dongligui.png" alt="" srcset="" />
            </div>
          </div>
          <div v-if="Number(item.devSn) % 2 == 0" @click="clickHandle(item)">
            <luotong_l :data="item"></luotong_l>
          </div>
          <div v-if="Number(item.devSn) % 2 != 0" @click="clickHandle(item)">
            <luotong_r :data="item"></luotong_r>
          </div>
          <div v-if="index == 6">
            <div class="wendu">
              <img src="@/assets/img/wendu.png" alt="" srcset="" />
            </div>
          </div>
        </div>
      </div>
      <div class="luotong_row3">
        <div
          class="item1"
          v-for="(item, index) in luoTongData.luotongRow2Data"
          :key="index + '2'"
        >
          <!-- 待修改 -->
          <div v-if="index <= 9">
            <div v-if="index == 1 || index == 10">
              <div class="dongli" @click="clickHandleDl('luotong3_' + index)">
                <img src="@/assets/img/dongligui.png" alt="" srcset="" />
              </div>
            </div>
            <div v-if="Number(item.devSn) % 2 == 0" @click="clickHandle(item)">
              <luotong_l :data="item"></luotong_l>
            </div>
            <div v-if="Number(item.devSn) % 2 != 0" @click="clickHandle(item)">
              <luotong_r :data="item"></luotong_r>
            </div>
            <div v-if="index == 5">
              <div class="wendu1">
                <img src="@/assets/img/wendu.png" alt="" srcset="" />
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- 络筒弹窗控件 -->
    <luoTongDialog ref="luoTongDialog"></luoTongDialog>
    <!-- 动力柜弹窗控件 -->
    <dongliDialog ref="dongliDialog"></dongliDialog>
  </div>
</template>

<script>
import luoTongDialog from '../qcs/dialog/dialog_luotong/index';
import dongliDialog from '../qcs/dialog/dialog_dongli/index';
import luotong_l from '../qcs/luotong_l';
import luotong_r from '../qcs/luotong_r';
import COMMON from '@/utils/common';
import dongLiMenu from '../data/dongli.json';
import dongliItem from '../data/dongliItem.json';
export default {
  name: 'LuoTong',
  props: {
    msg: String
  },
  components: {
    luoTongDialog,
    luotong_l,
    luotong_r,
    dongliDialog
  },
  data() {
    return {
      luoTongData: {
        luotongRow1Data: [],
        luotongRow2Data: []
      },
      dongLiMenu: {},
      dongLiItem: {}
    };
  },
  created() {
    this.dongLiMenu = dongLiMenu;
    this.dongLiItem = dongliItem;
  },
  computed: {
    luoTongGroupState() {
      return this.$store.state.workshop.luoTongGroupState;
    }
  },
  watch: {
    luoTongGroupState: {
      immediate: true,
      handler(val) {
        // console.log("luoTongval.data",val.data)
        this.luoTongData.luotongRow1Data = COMMON.devSnFilter(val.data, 1, 14);
        this.luoTongData.luotongRow2Data = COMMON.devSnFilter(
          val.data,
          15,
          val.data.length
        );
      }
    }
  },
  methods: {
    closeHandle() {
      this.$parent.$parent.$parent.closeParentHandle();
    },
    clickHandle(item) {
      this.$parent.$parent.$parent.getInfoByDevSn('LUOTONG', item.devSn);
      this.$refs.luoTongDialog.showDialog(item);
    },
    clickHandleDl(item) {
      var getInfoQuary = this.dongLiMenu[item];
      var dialogData = this.dongLiItem[item];
      this.$parent.$parent.$parent.getInfoByDevSn('DONGLI', getInfoQuary);
      this.$refs.dongliDialog.showDialog(dialogData);
    }
  }
};
</script>

<style scoped></style>
